Skip to content

[Fix] 재지원 플로우 지원 순번 저장 방식 수정#82

Merged
whc9999 merged 5 commits into
mainfrom
fix/sequence
May 26, 2026
Merged

[Fix] 재지원 플로우 지원 순번 저장 방식 수정#82
whc9999 merged 5 commits into
mainfrom
fix/sequence

Conversation

@whc9999
Copy link
Copy Markdown
Collaborator

@whc9999 whc9999 commented May 26, 2026

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

  • mock_applies에 sequence 필드 추가
  • 모의 서류 지원 생성 request에서 sequence를 받을 수 있도록 수정
  • 요청 sequence가 있으면 저장하고 없으면 기존 공고 기준 순번을 자동 계산
  • 답변 저장 및 분석 응답에서 저장된 sequence를 우선 반환하도록 수정
  • 기존 sequence null 데이터는 기존 계산 방식으로 fallback 처리
  • 재지원 플로우의 sequence 반환 테스트 추가

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [ ]

Summary by CodeRabbit

  • New Features

    • You can now provide an explicit application sequence when creating actual or mock applications; if omitted the system computes one. API responses include the sequence.
  • Bug Fixes

    • Enforced per-user+posting+sequence uniqueness; conflicts return clearer errors and creation retries handle concurrent conflicts.
  • Tests

    • Added tests ensuring sequence is validated, persisted, and returned across creation, analysis, and answer-saving flows.
  • Documentation

    • API success examples updated to include the sequence field.

Review Change Stack

- mock_applies에 sequence 필드 추가
- 모의 서류 지원 생성 request에서 sequence를 받을 수 있도록 수정
- 요청 sequence가 있으면 저장하고 없으면 기존 공고 기준 순번을 자동 계산
- 답변 저장 및 분석 응답에서 저장된 sequence를 우선 반환하도록 수정
- 기존 sequence null 데이터는 기존 계산 방식으로 fallback 처리
- 재지원 플로우의 sequence 반환 테스트 추가
@whc9999 whc9999 self-assigned this May 26, 2026
@whc9999 whc9999 added the fix label May 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 805f5795-56bf-4530-a9fa-750bc2096ad7

📥 Commits

Reviewing files that changed from the base of the PR and between 2a6e59a and fc455da.

📒 Files selected for processing (1)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java

📝 Walkthrough

Walkthrough

Adds optional validated sequence to mock-apply requests, persists sequence on MockApply (unique constraint updated), centralizes sequence resolution and retrying persistence in the service (using a REQUIRES_NEW helper), updates controller and responses to propagate sequence, and extends tests to assert stored sequences.

Changes

Mock Application Explicit Sequence Support

Layer / File(s) Summary
Request Contracts and Validation
src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateActualRequest.java, src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateMockFromJobPostingRequest.java, src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateMockRequest.java
Three request DTOs are extended with optional sequence fields annotated with @Positive. Each adds a convenience constructor that defaults sequence to null.
Entity and Response Contracts
src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApply.java, src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/response/MockApplyCreateResponse.java
MockApply adds a persisted sequence field, updates the unique constraint to include sequence, and adds a factory overload; MockApplyCreateResponse now includes sequence populated from the entity.
Transactional Persistence Helper
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyPersistenceService.java
Introduces a small service that calls repository saveAndFlush inside a REQUIRES_NEW transaction to support isolated, retryable persistence of sequence-aware MockApply records.
Service Sequence Resolution and Creation
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
Service adds overloads accepting optional sequence, a resolveSequence helper, and saveMockApplyWithSequence(...) which computes or uses a provided sequence and retries on conflicts, throwing specific errors for explicit conflicts or retry exhaustion. createMockApply and other creation paths now call the sequence-aware save. getMockApplySequence validation is relaxed to only reject sequence < 1.
Repository Sequence Reuse
src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
calculateSequence short-circuits to return an existing non-null positive sequence from the entity instead of recalculating via counts.
Controller Request Forwarding
src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
Controller methods forward request.sequence() to the corresponding service overloads for actual and mock-from-job-posting creation and update OpenAPI examples to include sequence in results.
Test Assertions for Sequence Handling
src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java, src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java, src/test/java/com/jobdri/jobdri_api/domain/analysis/service/QuestionServiceTest.java
Tests updated/added to verify that returned responses and persisted entities include the expected sequence, and downstream analysis/question flows preserve stored sequence values. Test helpers were refactored to persist entities inside new transactions for isolation.

Sequence Diagram

sequenceDiagram
  participant Controller as MockApplyController
  participant Service as MockApplyService
  participant Persistence as MockApplyPersistenceService
  participant Repo as MockApplyRepository
  participant DB as Database

  Controller->>Service: createActualApply(user, jobPostingId, sequence?)
  Service->>Repo: resolveSequence(userId, jobPostingId, sequence?)
  Repo->>DB: countByUserIdAndJobPostingId(userId, jobPostingId) (if needed)
  DB-->>Repo: count
  Repo-->>Service: computedSequence
  Service->>Persistence: saveAndFlush(MockApply with sequence)
  Persistence->>Repo: saveAndFlush(MockApply)
  Repo->>DB: insert MockApply
  DB-->>Repo: success / DataIntegrityViolation
  Repo-->>Persistence: result / exception
  Persistence-->>Service: saved MockApply or exception
  Service->>Service: on conflict -> increment sequence and retry (bounded)
  Service-->>Controller: MockApplyCreateResponse(jobPostingId, mockApplyId, applyType, sequence)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • JobDri-Developer/BackEnd#79: Modifies mock-apply sequence computation at the repository level, directly related to the sequence calculation refactoring in this PR.
  • JobDri-Developer/BackEnd#67: Related changes touching mock-apply sequence handling and service validation paths.

Suggested reviewers

  • shinae1023

Poem

🐰 I hopped through DTOs, entity, and test,
A sequence tucked in, now neatly dressed,
Controller passes it down the line,
Persistence retries until it's fine,
Tests cheer: the order's kept and blessed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing the way the support sequence is saved in the reapplication flow.
Description check ✅ Passed The description covers the purpose (code improvement and fix), detailed implementation (sequence field addition, auto-assignment logic, retry logic, fallback handling), and test additions. All required template sections are addressed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sequence

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java (1)

85-93: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Swagger success examples are stale after adding sequence to create responses.

These endpoints now return MockApplyCreateResponse with sequence, but the documented 200 examples still omit it. Update the example JSON to include "sequence": <number> so API docs match runtime behavior.

Also applies to: 129-141

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java`
around lines 85 - 93, Update the Swagger 200 response examples for the endpoints
that return MockApplyCreateResponse (notably the controller methods
createActualApply and the other create endpoint around lines 129-141) so the
example JSON includes the new "sequence" integer field; locate the
`@ApiResponse/`@Operation example JSON tied to MockApplyCreateResponse and add
"sequence": <number> (e.g., 1) to the example payload so the documented 200
response matches the runtime MockApplyCreateResponse structure returned by
mockApplyService.createActualApply and the corresponding create method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`:
- Around line 191-199: The current resolveSequence(User, JobPosting, Integer)
uses count+1 which races under concurrent requests; modify
MockApplyService.resolveSequence to allocate sequences atomically by adding a DB
unique constraint on (user_id, job_posting_id, sequence) and changing the
allocation path to either (A) perform the allocation inside a DB
lock/transaction (e.g., SELECT MAX(sequence) FOR UPDATE on the relevant rows and
return max+1) or (B) implement a retry-on-conflict loop around
mockApplyRepository.save/create that catches the
unique-constraint/DataIntegrityViolationException and retries with an
incremented sequence; ensure the repository/entity (mockApplyRepository /
MockApply entity) has the new unique index so conflicts surface for retry.

---

Outside diff comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java`:
- Around line 85-93: Update the Swagger 200 response examples for the endpoints
that return MockApplyCreateResponse (notably the controller methods
createActualApply and the other create endpoint around lines 129-141) so the
example JSON includes the new "sequence" integer field; locate the
`@ApiResponse/`@Operation example JSON tied to MockApplyCreateResponse and add
"sequence": <number> (e.g., 1) to the example payload so the documented 200
response matches the runtime MockApplyCreateResponse structure returned by
mockApplyService.createActualApply and the corresponding create method.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d63d049-8fa4-49a2-86bf-9f61e130fe0f

📥 Commits

Reviewing files that changed from the base of the PR and between e50514d and 7c511cf.

📒 Files selected for processing (11)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateActualRequest.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateMockFromJobPostingRequest.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/request/MockApplyCreateMockRequest.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/dto/response/MockApplyCreateResponse.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApply.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/repository/MockApplyRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java
  • src/test/java/com/jobdri/jobdri_api/domain/analysis/service/QuestionServiceTest.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

- mock_applies에 사용자, 공고, 순번 기준 유니크 제약 추가
- 자동 순번 생성 중 중복 충돌이 발생하면 다음 순번으로 재시도하도록 수정
- 요청으로 전달된 sequence가 이미 사용 중이면 잘못된 요청으로 예외 처리
- 모의 서류 지원 생성 응답 Swagger 예시에 sequence 필드 추가
- 중복 sequence 요청 예외 테스트 추가
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java (1)

194-197: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Enforce positive sequence in service-level validation.

Line 195 currently accepts caller-provided sequence as-is. Since these are public service overloads, 0/negative values can bypass controller DTO validation and be stored.

🔧 Suggested fix
 private int resolveSequence(User user, JobPosting jobPosting, Integer requestedSequence) {
     if (requestedSequence != null) {
+        if (requestedSequence < 1) {
+            throw new GeneralException(
+                    GeneralErrorCode.INVALID_PARAMETER,
+                    "지원 순번은 1 이상이어야 합니다. sequence=" + requestedSequence
+            );
+        }
         return requestedSequence;
     }
     return Math.toIntExact(mockApplyRepository.countByUserIdAndJobPostingId(
             user.getId(),
             jobPosting.getId()
     )) + 1;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`
around lines 194 - 197, The resolveSequence method currently returns any
non-null requestedSequence; change it to only accept and return
requestedSequence when it's positive (requestedSequence != null &&
requestedSequence > 0), otherwise ignore it and compute the next valid sequence
number (e.g., query the existing max sequence for the JobPosting via the
repository/service and return max+1). Update resolveSequence(User user,
JobPosting jobPosting, Integer requestedSequence) to enforce this check and
fallback to the existing sequence-allocation logic so 0 or negative values are
never persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`:
- Around line 194-197: The resolveSequence method currently returns any non-null
requestedSequence; change it to only accept and return requestedSequence when
it's positive (requestedSequence != null && requestedSequence > 0), otherwise
ignore it and compute the next valid sequence number (e.g., query the existing
max sequence for the JobPosting via the repository/service and return max+1).
Update resolveSequence(User user, JobPosting jobPosting, Integer
requestedSequence) to enforce this check and fallback to the existing
sequence-allocation logic so 0 or negative values are never persisted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fb5543fb-3673-4d08-a49e-a2e63442eb8a

📥 Commits

Reviewing files that changed from the base of the PR and between 7c511cf and cac86e5.

📒 Files selected for processing (4)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/controller/MockApplyController.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApply.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java
✅ Files skipped from review due to trivial changes (1)
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

- 요청 sequence가 양수일 때만 명시 순번으로 사용하도록 수정
- 0 또는 음수 sequence 요청은 자동 순번 할당 로직으로 처리
- 중복 순번 충돌 처리 기준을 양수 sequence 요청으로 제한
- 0 이하 sequence 요청 시 다음 유효 순번이 저장되는 테스트 추가
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java (1)

214-225: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Fix unsafe retry loop: don’t continue using the same transaction/session after saveAndFlush throws unique-constraint DataIntegrityViolationException.

When the insert fails on the unique constraint, Spring/JPA/Hibernate typically marks the current transaction and persistence context as rollback-only/invalid, so the later sequence++ retry attempts inside the same @Transactional flow are unreliable and may still end up failing/rolling back. Move each attempt into a fresh transaction boundary (e.g., extract the save into a @Transactional(propagation = REQUIRES_NEW) method called per retry), or use an atomic/locking-based sequence allocation approach to avoid the constraint violation in the first place. (src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java: 214-225)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`
around lines 214 - 225, The retry loop in MockApplyService that calls
mockApplyRepository.saveAndFlush(MockApply.create(...)) inside the same
transaction is unsafe because a DataIntegrityViolationException leaves the
transaction/persistence context invalid; extract the save-and-flush into a new
transactional boundary (create a helper method, e.g.,
saveMockApplyInNewTx(MockApply) annotated with `@Transactional`(propagation =
REQUIRES_NEW)) and call that on each retry so each attempt uses a fresh
transaction, or alternatively implement an atomic sequence allocator/DB lock to
claim sequence numbers before persisting; update the loop to call the new method
instead of saveAndFlush directly and increment sequence between new-transaction
attempts.
🧹 Nitpick comments (1)
src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java (1)

113-129: ⚡ Quick win

This doesn't exercise the new retry path.

Both calls still take the happy path where count + 1 is available, so this only proves that non-positive inputs fall back to auto-allocation. Please add one deterministic case where count + 1 is already occupied by an explicit stored sequence and assert that auto-allocation advances to the next free value.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java`
around lines 113 - 129, Add a deterministic case that exercises the retry path
by pre-inserting a MockApply with the "count + 1" sequence before calling
mockApplyService.createActualApply with a non-positive requested sequence;
specifically, in MockApplyServiceTest
createActualApplyIgnoresNonPositiveRequestedSequence, save a MockApply (via the
repository or existing test helper) for the same jobPosting with sequence equal
to the current count + 1 so the first auto-allocated value is occupied, then
call createActualApply(user, jobPosting.getId(), 0) (or -1) and assert the
returned sequence and the persisted MockApply sequence advance to the next free
value (e.g., count + 2). Ensure you reference mockApplyService.createActualApply
and mockApplyRepository.findById/mockApplyRepository.save to locate where to
insert the setup and assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`:
- Around line 214-225: The retry loop in MockApplyService that calls
mockApplyRepository.saveAndFlush(MockApply.create(...)) inside the same
transaction is unsafe because a DataIntegrityViolationException leaves the
transaction/persistence context invalid; extract the save-and-flush into a new
transactional boundary (create a helper method, e.g.,
saveMockApplyInNewTx(MockApply) annotated with `@Transactional`(propagation =
REQUIRES_NEW)) and call that on each retry so each attempt uses a fresh
transaction, or alternatively implement an atomic sequence allocator/DB lock to
claim sequence numbers before persisting; update the loop to call the new method
instead of saveAndFlush directly and increment sequence between new-transaction
attempts.

---

Nitpick comments:
In
`@src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java`:
- Around line 113-129: Add a deterministic case that exercises the retry path by
pre-inserting a MockApply with the "count + 1" sequence before calling
mockApplyService.createActualApply with a non-positive requested sequence;
specifically, in MockApplyServiceTest
createActualApplyIgnoresNonPositiveRequestedSequence, save a MockApply (via the
repository or existing test helper) for the same jobPosting with sequence equal
to the current count + 1 so the first auto-allocated value is occupied, then
call createActualApply(user, jobPosting.getId(), 0) (or -1) and assert the
returned sequence and the persisted MockApply sequence advance to the next free
value (e.g., count + 2). Ensure you reference mockApplyService.createActualApply
and mockApplyRepository.findById/mockApplyRepository.save to locate where to
insert the setup and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98bf8ebf-b116-43ed-a81a-9a8f279a0ee4

📥 Commits

Reviewing files that changed from the base of the PR and between cac86e5 and d39319a.

📒 Files selected for processing (2)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

- 순번 중복 충돌 후 재시도 시 새 트랜잭션에서 저장하도록 PersistenceService 추가
- 모의 서류 지원 생성 흐름의 외부 트랜잭션을 비활성화해 공고 저장 후 지원 저장 FK 참조 안정화
- 자동 순번 저장 중 충돌이 발생하면 다음 순번으로 재시도하도록 유지
- 0 이하 sequence 요청 시 중복 충돌을 거쳐 다음 유효 순번으로 저장되는 테스트 보강
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java (1)

217-228: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Narrow DataIntegrityViolationException handling to the sequence-unique constraint only

MockApplyService.java lines 220-227 catch all DataIntegrityViolationException and treat them as sequence conflicts (either throwing INVALID_PARAMETER for explicit sequences or retrying/incrementing for auto-assigned ones). This can misreport unrelated integrity failures and mask real DB/data issues.

Handle only the uk_mock_apply_user_posting_sequence (i.e., detect the underlying unique-constraint violation via the most specific cause/constraint name/SQLState) and rethrow for other DataIntegrityViolationException causes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`
around lines 217 - 228, The catch for DataIntegrityViolationException in
MockApplyService around mockApplyPersistenceService.saveAndFlush is too broad;
change it to inspect the exception cause (e.g., ConstraintViolationException /
SQLException) and only treat it as a sequence-unique conflict when the
underlying constraint name or SQL state indicates the
uk_mock_apply_user_posting_sequence violation—on that specific match keep the
current behavior (throw INVALID_PARAMETER when requestedSequence is positive,
otherwise increment and retry); for any other DataIntegrityViolationException
causes rethrow the original exception so unrelated integrity errors are not
masked.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java`:
- Around line 217-228: The catch for DataIntegrityViolationException in
MockApplyService around mockApplyPersistenceService.saveAndFlush is too broad;
change it to inspect the exception cause (e.g., ConstraintViolationException /
SQLException) and only treat it as a sequence-unique conflict when the
underlying constraint name or SQL state indicates the
uk_mock_apply_user_posting_sequence violation—on that specific match keep the
current behavior (throw INVALID_PARAMETER when requestedSequence is positive,
otherwise increment and retry); for any other DataIntegrityViolationException
causes rethrow the original exception so unrelated integrity errors are not
masked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f239bfb-7e22-4a30-af94-9bb367cee982

📥 Commits

Reviewing files that changed from the base of the PR and between d39319a and 2a6e59a.

📒 Files selected for processing (3)
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyPersistenceService.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyService.java
  • src/test/java/com/jobdri/jobdri_api/domain/mockapply/service/MockApplyServiceTest.java

- DataIntegrityViolationException 발생 시 순번 유니크 제약 위반 여부를 확인하도록 수정
- uk_mock_apply_user_posting_sequence 제약 위반일 때만 순번 재시도 로직 수행
- 명시 sequence 중복 요청은 기존처럼 잘못된 요청 예외로 처리
- FK 오류 등 다른 무결성 오류는 원본 예외를 그대로 전파하도록 변경
@whc9999 whc9999 merged commit e599bf0 into main May 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant